<template>
  <div>
    <van-swipe-cell>
      <router-link to="/xiao/index">
        <div class="zong" @click="changeShow">

          <van-badge :dot="show" class="a1tu">
            <img src="../../images/image.png" alt="" />
            <div class="child" />
          </van-badge>

          <div style="width: 1rem; height: 100%; float: right">
            <van-tag :show="show2" size="medium" type="primary"> 置顶 </van-tag>
          </div>
          <span class="xiao">系统消息</span>
          <div class="tui">近期热门推荐</div>
        </div>
      </router-link>

      <template #right>
        <van-button square :text="zhi" class="delete-button" @click="zd" />
        <van-button square :text="biao" class="du-button" @click="wd" />
      </template>
    </van-swipe-cell>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
// localStorage.setItem("show","true")
const show:any = ref(localStorage.getItem('show')) //小圆点 
const show2:any = ref(localStorage.getItem('show2')) //置顶标志
if(show.value=="true"){
  show.value=true
}else{
  show.value=false
}
if(show2.value=="true"){
  show2.value=true
}else{
  show2.value=false
}
const zhi = ref('置顶')
const biao = ref('标为未读')
const wd = () => {
  if(show.value==true){
    biao.value='标为未读'
    show.value = false
  }else{
    biao.value='标为已读'
    show.value = true
  }
}
if(show.value == true){
  biao.value='标为已读'
}else{
  biao.value='标为未读'
}

const changeShow=()=>{
    show.value=false
    localStorage.setItem('show','false')
    localStorage.setItem('show2','true')
}
const zd = () => {
  if (zhi.value == '置顶') {
    zhi.value = '已置顶'
    show2.value = true
  } else if (zhi.value == '已置顶') {
    zhi.value = '置顶'
    show2.value = false
  }
}
if(show2.value == true){
 zhi.value = '已置顶'
}else{
  zhi.value = '置顶'
}
</script>

<style lang="scss">
* {
  text-decoration: none;
}
.zong {
  width: 100vw;
  height: 9.5vh;
  font-size: 0.44rem;
  margin-top: 0.7rem;
  border-bottom: 1px solid #ccc;
  padding: 0.2rem;
}
.a1tu {
  float: left;
  margin-right: 0.2rem;
  img {
    width: 1rem;
    height: 1rem;
  }
}
.tui {
  font-size: 0.27rem;
  color: #aaa;
}
.delete-button {
  height: 100%;
  width: 1.2rem;
  background-color: rgb(159, 158, 158) !important;
  color: #fff;
}
.du-button {
  height: 100%;
  width: 1.2rem;
  background-color: rgb(245, 165, 16) !important;
  color: #fff;
}
</style>
